// createStore已弃用
import {
  legacy_createStore as createStore,
  applyMiddleware,
  combineReducers,
} from "redux";

// 引入开发者工具
import { composeWithDevTools } from "redux-devtools-extension";

// 引入为Count组件服务的reducer
import counterReducer from "./reducers/count";
//引入为Person组件服务的reducer
import personReducer from "./reducers/person";

//  使用 Thunk Middleware 来做"异步" Action
import thunk from "redux-thunk";

// 合并reducer
const allReducers = combineReducers({
  count: counterReducer,
  personList: personReducer,
});

/**
 * 这样只能使用一个reducer
 */
// export default createStore(counterReducer, applyMiddleware(thunk));

/**
 * 使用合并的reducers
 */
// export default createStore(allReducers, applyMiddleware(thunk));

/**
 * 使用开发者工具
 */
export default createStore(
  allReducers,
  composeWithDevTools(applyMiddleware(thunk))
);
